import axios from 'axios'
import request from '@/utils/request'

/**
 * 文件上传接口(图片-视频)
 * @param {s} data 
 * @returns 
 */
export function uploadFile(data, filename) {
  let formData = new FormData()
  formData.append("file", data, filename)
  return new Promise((resolve, reject) => {
    return axios.post(import.meta.env.VITE_APP_BASE_API + '/api/common/uploadFile', formData, {
      headers: {
        'Content-Type': 'multipart/form-data'
      }
    }).then(res => {
      return res.data || {}
    }).then(resolve)
      .catch(reject)
  })
}

// 系统消息列表
export function getNoticeList(query) {
  return request({
    url: '/api/member/noticeList',
    method: 'get',
    params: query,
  })
}

// 阅读消息
export function readNotice(id) {
  return request({
    url: '/api/member/readNotice',
    method: 'get',
    params: { id },
  })
}

// 阅读全部消息
export function readAllNotice() {
  return request({
    url: '/api/member/readAllNotice',
    method: 'post',
    headers: {
      'Content-Type': 'application/json'
    },
  })
}

// 区域列表
export function getAreas(query) {
  console.log('getAreas query:', query)
  return request({
    url: '/api/common/getAreas',
    method: 'get',
    headers: {
      isToken: false
    },
    params: query,
  })
}

// 公司资质类型
export function getCompanyQualificationTypes(query) {
  return request({
    url: '/api/common/getCompanyQualificationTypes',
    method: 'get',
    headers: {
      isToken: false
    },
    params: query,
  })
}

// 项目人员类型
export function getProjectPersonnelTypes(query) {
  return request({
    url: '/api/common/getProjectPersonnelTypes',
    method: 'get',
    headers: {
      isToken: false
    },
    params: query,
  })
}

// 注册证书类型
export function getRegisterCertificateTypes(query) {
  return request({
    url: '/api/common/getRegisterCertificateTypes',
    method: 'get',
    headers: {
      isToken: false
    },
    params: query,
  })
}

// 查询系统设置
export function getSysConfig(query) {
  return request({
    url: '/api/common/getSysConfig',
    method: 'get',
    headers: {
      isToken: false
    },
    params: query,
  })
}

// 文本信息
export function getText(query) {
  return request({
    url: '/api/common/getText',
    method: 'get',
    headers: {
      isToken: false
    },
    params: query,
  })
}
